package com.zzty.zzlp.dao;

import com.zzty.zzlp.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;


public interface UserMapper {

    @Select("select * from user where name=#{name}")
    User selectByName(@Param("name") String name);

    @Insert("insert into user(name,password,email,phone,sex,clazzId,img,disname)values(#{name},#{password},#{email},#{phone},#{sex},#{clazzId},#{img},#{disname})")
    public void addUser(User user);

    @Update("update user set email=#{email},phone=#{phone}, sex=#{sex} ,clazzId=#{clazzId}, disname=#{disname} where name=#{name}")
    public void updateUser(@Param("email") String email, @Param("phone") String phone, @Param("sex") String sex,
                           @Param("clazzId") Integer clazzId, @Param("disname") String disname, @Param("name") String name);

    @Update("update user set password=#{password} where name=#{name}")
    public void updatePwd(@Param("password") String password, @Param("name") String name);

    @Update("update user set img=#{img} where name=#{name}")
    public void changeImg(@Param("name") String name);

    @Select("select password from user where name=#{name} and email=#{email}")
    public String findPwd(@Param("name") String name, @Param("email") String email);

    @Select("select Id from user where clazzId=#{clazzId} and type is null")
    public List<Integer> searchStuIdByclazzId(@Param("clazzId") Integer clazzId);

    @Select("select password from user where name = #{name}")
    public String searchPwdByName(@Param("name") String name);

//    public User selectUserInfo(User user);

    @Select("select * from user where id = #{id}")
    public User selectUserById(@Param("id") Integer id);

    @Select("select * from user where name = #{name}")
    public User selectUserByName(@Param("name") String name);

    @Select("#{sql}")
    public List<User> selectBySql(String sql);

    @Select("select * from user where name = #{name}")
    public User getUserByName(String name);

    @Select("select disname from user where id = #{id}")
    public String getDisnameById(@Param("id") Integer id);

    @Select("select * from user where clazzId=#{clazzId} and type is null")
    public List<User> searchStuByclazzId(@Param("clazzId") Integer clazzId);

}